package com.wis.traffic.post.service.impl;

import com.wis.traffic.post.base.PostBaseDAOImpl;
import com.wis.traffic.post.service.RiskIndexService;
import com.wis.traffic.entity.base.BaseDAO;
import com.wis.traffic.entity.dao.RiskIndex;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

public class RiskIndexServiceImpl implements RiskIndexService {
    private String nameSpace = RiskIndex.class.getName();
    private BaseDAO<RiskIndex, Serializable> baseDao = new PostBaseDAOImpl<>();

    @Override
    public List<Object> getByParams(Map<String, Object> params) {
        return baseDao.getObject(nameSpace,"selectRiskIndexByParams",params);
    }

    @Override
    public List<Object> getDiffAreasFromRiskIndex(Map<String, Object> params) {
        return baseDao.getObject(nameSpace,"selectDiffAreasFromRiskIndex",params);
    }

    @Override
    public List<Object> getDiffPointsFromRiskIndex(Map<String, Object> params) {
        return baseDao.getObject(nameSpace,"selectDiffPointsFromRiskIndex",params);
    }

    @Override
    public Integer insertOrUpdate(RiskIndex riskIndex) {
        if(riskIndex.getId()==null || riskIndex.getId()==0){
            //新增
            return baseDao.insert(nameSpace,riskIndex);
        }else {
            //更新
            return baseDao.update(nameSpace,riskIndex);
        }
    }

    @Override
    public Integer insertBatch(List riskIndices) {
        return baseDao.insertBatch(nameSpace,riskIndices);
    }
}
